package com.whfc.cncit.helmet.codec;

import com.whfc.cncit.constant.CncitConst;
import com.whfc.cncit.entity.CncitDwMsgPS;
import com.whfc.iot.util.ByteUtil;

/**
 * @author : qzexing
 * @version : 1.0
 * @date : 2020/7/1 17:21
 */
public class CncitDwMsgCodecPS implements CncitMsgCodec<CncitDwMsgPS> {

    @Override
    public CncitDwMsgPS decode(String data) {
        return null;
    }

    @Override
    public String encode(CncitDwMsgPS msg) {
        String data;
        //$16,PS,0,TTSD,你好,#\n
        String dataLengthStr = ByteUtil.toHexString(msg.getDataLength());
        data = String.format("$%s,%s,%s,%s,%s,#", dataLengthStr, msg.getCmd(), CncitConst.PLATFORM, msg.getType(), msg.getParam());
        return data;
    }
}
